﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace GraphicsEditor
{
    public class DrawingTool : PixelClick
    {
        public Point pixelDown, pixelUp;
        public Bitmap cleanBitmap;
        public bool dirty = false;
        protected int drawTime = 0;
        public DrawingTool()
        {
            pixelDown = new Point(0, 0);
            pixelUp = new Point(0,0);
        }

        public virtual void setMouseDown(Point mouseLoc, PictureBoxAdvance pictureWindow)
        {
            pixelDown = pixelUp = getPixelPositionUsingMouse(mouseLoc, pictureWindow);
            cleanBitmap = new Bitmap(pictureWindow.Image);
            dirty = true;

        }

        public virtual void copy(PictureBoxAdvance pictureWindow)
        {

        }

        public virtual void cut(PictureBoxAdvance pictureWindow)
        {

        }

        public virtual void deleteSelected(PictureBoxAdvance pictureWindow)
        {

        }

        public virtual void paste(Image image)
        {

        }

        public virtual void deselect(PictureBoxAdvance pictureWindow, ImageForm imgForm)
        {

        }

        public virtual RectangleF currentRectangle()
        {
            return getRectFromPoints(pixelDown, pixelUp);
        }

        public virtual void mouseMoved(Point mouseLoc, PictureBoxAdvance pictureWindow, ImageForm imageform, bool mouseDown)
        {
            if (mouseDown)
            {
                pixelUp = getPixelPositionUsingMouse(mouseLoc, pictureWindow);
                drawTime++;
                if (drawTime >= 3)
                {
                    dirty = true;
                    //paintSelection(null, pictureWindow, false);
                    //drawTime = 0;
                }
            }
        }

        public virtual void setMouseUp(Point mouseLoc, PictureBoxAdvance pictureWindow)
        {
            pixelUp = getPixelPositionUsingMouse(mouseLoc, pictureWindow);
            paintSelection(null, pictureWindow, false);
        }

        public virtual void paintSelection(Graphics gfx, PictureBoxAdvance pictureWindow, bool zoom)
        {

        }

        public virtual bool handleInput(Keys key, PictureBoxAdvance pictureWindow)
        {
            return false;
        }
    }
}
